package com.ia.aistream.service.operating.impl;

import com.ia.aistream.mapper.operating.DocContentParagraphMapper;
import com.ia.aistream.mapper.operating.DocTitleMapper;
import com.ia.aistream.model.operating.entity.DocContentParagraph;
import com.ia.aistream.model.operating.entity.DocTitle;

import com.ia.aistream.service.operating.IDocAnalysisTableOrParagraphService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;
@Service
public class DocAnalysisTableOrParagraphServiceImpl implements IDocAnalysisTableOrParagraphService {
    @Autowired
    private DocContentParagraphMapper docContentParagraphMapper;

    @Autowired
    private DocTitleMapper docTitleMapper;


    @Transactional
    @Override
    public Integer add(Map<String, Object> map) {
        DocTitle docTitle = (DocTitle)map.get("docTitle");
        List<DocContentParagraph> list = (List<DocContentParagraph>)map.get("docContentParagraphList");
        int id = docTitleMapper.insertDocTitle(docTitle);
        for (DocContentParagraph doc : list) {
            doc.setDocTitleId(id+"");
        }
        int result = docContentParagraphMapper.inserDocContentParagraphList(list);
        return result;
    }
}
